package cn.iocoder.yudao.module.blog.controller.app.jiutagclassity;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.blog.controller.admin.jiutagclassity.vo.BlogJiuTagClassityCreateReqVO;
import cn.iocoder.yudao.module.blog.controller.admin.jiutagclassity.vo.BlogJiuTagClassityRespVO;
import cn.iocoder.yudao.module.blog.convert.jiutagclassity.BlogJiuTagClassityConvert;
import cn.iocoder.yudao.module.blog.dal.dataobject.jiutagclassity.BlogJiuTagClassityDO;
import cn.iocoder.yudao.module.blog.service.jiutagclassity.BlogJiuTagClassityService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 案例标签类型")
@RestController
@RequestMapping("/blog/tag-classity")
@Validated
@Slf4j
public class AppBlogJiuTagClassityController {
    @Resource
    private BlogJiuTagClassityService jiuTagClassityService;

    @PostMapping("/create")
    @Operation(summary = "创建案例标签分类")
    public CommonResult<Long> createJiuTagClassity(@Valid @RequestBody BlogJiuTagClassityCreateReqVO createReqVO) {
        return success(jiuTagClassityService.createJiuTagClassity(createReqVO));
    }

    @GetMapping("/all")
    @Operation(summary = "获取所有标签")
    public CommonResult<List<BlogJiuTagClassityRespVO>> getAll(){
        List<BlogJiuTagClassityDO> list = jiuTagClassityService.getAll();
        return success(BlogJiuTagClassityConvert.INSTANCE.convertList(list));
    }
}
